package top.toptimus.dto.order.orderSync.orderCommit;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import top.toptimus.util.ValueUtil;

import java.util.Map;

/**
 * 设计点DTO
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class DTODesignPoints {
    private String itemTypeNameCn;
    private String itemCd;
    private String itemValue;
    private String optionValue;
    private String enableFlag;
    private String deleteFlag;
    private String defaultValue;

    //  设计点名称
    private String name;
    private String styleId;//款式id

    public DTODesignPoints(String styleId, Map<String, Object> stringObjectMap) {
        this.itemTypeNameCn = stringObjectMap.containsKey("ITEM_TYPE_NAME_CN") ? ValueUtil.objectToSting(stringObjectMap.get("ITEM_TYPE_NAME_CN")) : "";
        this.itemCd = stringObjectMap.containsKey("ITEM_CD") ? ValueUtil.objectToSting(stringObjectMap.get("ITEM_CD")) : "";
        this.itemValue = stringObjectMap.containsKey("ITEM_VALUE") ? ValueUtil.objectToSting(stringObjectMap.get("ITEM_VALUE")) : "";
        this.optionValue = stringObjectMap.containsKey("OPTION_VALUE") ? ValueUtil.objectToSting(stringObjectMap.get("OPTION_VALUE")) : "";
        this.enableFlag = stringObjectMap.containsKey("ENABLE_FLAG") ? ValueUtil.objectToSting(stringObjectMap.get("ENABLE_FLAG")) : "";
        this.deleteFlag = stringObjectMap.containsKey("DELETE_FLAG") ? ValueUtil.objectToSting(stringObjectMap.get("DELETE_FLAG")) : "";
        this.name = stringObjectMap.containsKey("ITEM_NAME_CN") ? ValueUtil.objectToSting(stringObjectMap.get("ITEM_NAME_CN")) : "";
        this.styleId = styleId;
    }

    /**
     * 更新设计点
     *
     * @param designPoint 设计点
     */
    public void build(DTODesignPoints designPoint) {
        this.optionValue = designPoint.getOptionValue();
        this.name = designPoint.getName();
    }
}
